class Solution {
    public int maxScoreSightseeingPair(int[] values) {
        int ans = 0;
        int left = values[0];
        for(int i = 1;i<values.length;i++){
            left-=1;
            ans = Math.max(left + values[i],ans);
            if(left < values[i])left = values[i];
        }return ans;
    }
}